package com.lxm.controller;

import com.lxm.dto.Result;
import com.lxm.service.FollowService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 关注表 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2024-10-02
 */
@RestController
@RequestMapping("/user/follow")
@Tag(name = "关注管理")
public class FollowController {
    @Resource
    private FollowService followService;

    @Operation(summary = "关注用户")
    @GetMapping("/add/{followeeId}")
    public Result followUser(@PathVariable Long followeeId) {
        return followService.followUser(followeeId);
    }

    @Operation(summary = "获取用户关注的所有博主的id")
    @GetMapping("/getAllFolloweeId")
    public Result getAllFolloweeId() {
        return followService.getAllFolloweeId();
    }

    @Operation(summary = "进入博客详情页时查看用户是否关注博主")
    @GetMapping("/check/{followeeId}")
    public Result checkFollow(@PathVariable Long followeeId) {
        return followService.checkFollow(followeeId);
    }

    @Operation(summary = "取消关注")
    @GetMapping("/delete/{followeeId}")
    public Result deleteFollow(@PathVariable Long followeeId) {
        return followService.deleteFollow(followeeId);
    }

    @Operation(summary = "分页获取用户关注的博主", description = "可以是用户自己也可是查看别人")
    @GetMapping("/followList")
    //这个是按照时间排序的关注信息
    public Result getUserFollowList(@RequestParam(name = "currentId", required = false, defaultValue = "1") Long currentId,
                                    @RequestParam(name = "userId", required = false) Long userId) {
        return followService.getUserFollowList(currentId, userId);
    }

    @Operation(summary = "分页获取用户粉丝列表", description = "可以是用户自己也可是查看别人")
    @GetMapping("/fanList")
    //这个是按照时间排序的粉丝信息
    public Result getUserFanList(@RequestParam(name = "currentId", required = false, defaultValue = "1") Long currentId,
                                 @RequestParam(name = "userId", required = false) Long userId) {
        return followService.getUserFanList(currentId, userId);
    }
}

